const key = "xy_admin_2004"
const userInfokey = "userInfo_2004"
export function setToken(token){
    window.localStorage.setItem(key,token);
}
export function getToken(){
    return window.localStorage.getItem(key);
}
export function removeToken(){
    window.localStorage.removeItem(key);
}

export function saveUserInfo(userInfo){
var userInfoStr = JSON.stringify(userInfo);
window.localStorage.setItem(userInfokey,userInfoStr)
}

export function getUserInfo(){
    var userInfoStr = window.localStorage.getItem(userInfokey);
    if(userInfoStr !== ''&& userInfoStr !== 'undefined'){
        return JSON.parse(userInfoStr)
    }else{
        return {}
    }
}

export function removeUserInfo(){
    window.localStorage.removeItem(userInfokey)
}

export function clearLogin(){
    removeToken();
    removeUserInfo()
}